using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace miciv
{
    public class HashtableManager<K, T> where T : class
    {
        protected Hashtable m_htblData;

        public HashtableManager()
        {
            this.m_htblData = new Hashtable();
        }

        public bool Add(K _key, T _data)
        {
            if (false == this.m_htblData.ContainsKey(_key))
            {
                this.m_htblData.Add(_key, _data);
                return true;
            }
            return false;
        }

        public void Remove(K _key)
        {
            if (false != this.m_htblData.ContainsKey(_key))
            {
                this.m_htblData.Remove(_key);
            }
        }

        public bool Exists(K _key)
        {
            return (false != this.m_htblData.ContainsKey(_key));
        }

        public T Get(K _key)
        {
            if (false != this.Exists(_key))
            {
                return this.m_htblData[_key] as T;
            }
            return default(T);
        }
    }
}
